package file;

import java.io.File;

public class ListFilesDemo {
    public static void main(String[] args) {
        File dir=new File(".");
        if (dir.isDirectory()){
            File[]files=dir.listFiles();
            System.out.println("共有："+files.length+"个子项");
            for (File file:files){
                System.out.println(file.getName());
            }
        }else {
            System.out.println("目录不存在");
        }
    }
}
